package com.itkim.judge.controller;

import java.util.List;
import java.util.Map;

import com.itkim.judge.domain.YzJudgeRes;
import com.itkim.work.domain.YzWorkRes;
import com.itkim.work.service.IYzWorkService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.itkim.judge.domain.YzJudge;
import com.itkim.judge.service.IYzJudgeService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评价管理Controller
 * 
 * @author itkim
 * @date 2024-06-07
 */
@Controller
@RequestMapping("/judge/manage")
public class YzJudgeController extends BaseController
{
    private String prefix = "judge/manage";

    @Autowired
    private IYzJudgeService yzJudgeService;

    @RequiresPermissions("judge:manage:view")
    @GetMapping()
    public String manage()
    {
        return prefix + "/manage";
    }

    /**
     * 查询评价管理列表
     */
    @RequiresPermissions("judge:manage:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(YzJudgeRes yzJudgeRes)
    {
        startPage();
        List<YzJudgeRes> list = yzJudgeService.selectYzJudgeList(yzJudgeRes);
        return getDataTable(list);
    }

    /**
     * 导出评价管理列表
     */
    @RequiresPermissions("judge:manage:export")
    @Log(title = "评价管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(YzJudgeRes yzJudgeRes)
    {
        List<YzJudgeRes> list = yzJudgeService.selectYzJudgeList(yzJudgeRes);
        ExcelUtil<YzJudgeRes> util = new ExcelUtil<YzJudgeRes>(YzJudgeRes.class);
        return util.exportExcel(list, "评价管理数据");
    }

    @Autowired
    private IYzWorkService yzWorkService;

    /**
     * 查看作品信息
     */
    @PostMapping("/look")
    @ResponseBody
    public Map<String,Object> look(YzJudgeRes yzJudgeRes){
        YzWorkRes yzWorkRes = new YzWorkRes();
        yzWorkRes.setWorkId(yzJudgeRes.getWorkId());
        return yzWorkService.look(yzWorkRes);
    }
    /**
     * 下载功能在yz-work模块中，url输入yz-work的下载url即可
     */
}
